package com.ruoyi.invest.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.invest.domain.TbInvestPapers;
import com.ruoyi.invest.service.ITbInvestPapersService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 投资证件Controller
 * 
 * @author ruoyi
 * @date 2023-01-13
 */
@RestController
@RequestMapping("/papers")
@CrossOrigin
public class TbInvestPapersController extends BaseController
{
    @Autowired
    private ITbInvestPapersService tbInvestPapersService;

    /**
     * 查询投资证件列表
     */
    @GetMapping("/list")
    public TableDataInfo list(TbInvestPapers tbInvestPapers)
    {
        startPage();
        List<TbInvestPapers> list = tbInvestPapersService.selectTbInvestPapersList(tbInvestPapers);
        return getDataTable(list);
    }

    /**
     * 导出投资证件列表
     */
    @Log(title = "投资证件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbInvestPapers tbInvestPapers)
    {
        List<TbInvestPapers> list = tbInvestPapersService.selectTbInvestPapersList(tbInvestPapers);
        ExcelUtil<TbInvestPapers> util = new ExcelUtil<TbInvestPapers>(TbInvestPapers.class);
        util.exportExcel(response, list, "投资证件数据");
    }

    /**
     * 获取投资证件详细信息
     */
    @GetMapping(value = "/{investPapersId}")
    public AjaxResult getInfo(@PathVariable("investPapersId") Long investPapersId)
    {
        return success(tbInvestPapersService.selectTbInvestPapersByInvestPapersId(investPapersId));
    }

    /**
     * 新增投资证件
     */
    @Log(title = "投资证件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbInvestPapers tbInvestPapers)
    {
        return toAjax(tbInvestPapersService.insertTbInvestPapers(tbInvestPapers));
    }

    /**
     * 修改投资证件
     */
    @Log(title = "投资证件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbInvestPapers tbInvestPapers)
    {
        return toAjax(tbInvestPapersService.updateTbInvestPapers(tbInvestPapers));
    }

    /**
     * 删除投资证件
     */
    @Log(title = "投资证件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{investPapersIds}")
    public AjaxResult remove(@PathVariable Long[] investPapersIds)
    {
        return toAjax(tbInvestPapersService.deleteTbInvestPapersByInvestPapersIds(investPapersIds));
    }
}
